package ar.uba.fi.RSACryptoFiuba.view.keygeneration;

import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.TitledBorder;

import ar.uba.fi.RSACryptoFiuba.view.commons.NavigableKeyActionListener;


@SuppressWarnings("serial")
public class GenerateKeysProgressPanel extends JPanel{
	
	private JLabel pLabel;
	private JTextField pValue;
	private JLabel qLabel;
	private JTextField qValue;
	private JLabel nLabel;
	private JTextField nValue;
	private JLabel phiLabel;
	private JTextField phiValue;
    private JLabel dLabel;
    private JTextField dValue;
    private JLabel eLabel;
    private JTextField eValue;
     	
	public GenerateKeysProgressPanel(){
		super();
		initComponentes();
	}
	
	private void initComponentes(){
		
        this.setBorder(BorderFactory.createTitledBorder(null, "Progreso", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION));
        this.setToolTipText("");
        
        pLabel = new JLabel();
        pLabel.setFont(new Font("Ubuntu", 1, 15));
        pLabel.setText("p:");

        pValue = new JTextField();
        pValue.setBackground(getBackground());
        pValue.setBorder(BorderFactory.createEmptyBorder());
        pValue.addKeyListener(new NavigableKeyActionListener());
        
        qLabel = new JLabel();
        qLabel.setFont(new Font("Ubuntu", 1, 15));
        qLabel.setText("q:");

        qValue = new JTextField(6);
        qValue.setBackground(getBackground());
        qValue.setBorder(BorderFactory.createEmptyBorder());
        qValue.addKeyListener(new NavigableKeyActionListener());
        
        nLabel = new JLabel();
        nLabel.setText("n:");
        nLabel.setFont(new Font("Ubuntu", 1, 15));
        
        nValue = new JTextField(6);
        nValue.setBackground(getBackground());
        nValue.setBorder(BorderFactory.createEmptyBorder());
        nValue.addKeyListener(new NavigableKeyActionListener());

        phiLabel = new JLabel();
        phiLabel.setFont(new Font("Ubuntu", 1, 15));
        phiLabel.setText("phi:");

        phiValue = new JTextField(6);
        phiValue.setBackground(getBackground());
        phiValue.setBorder(BorderFactory.createEmptyBorder());
        phiValue.addKeyListener(new NavigableKeyActionListener());
        
        dLabel = new JLabel();
        dLabel.setFont(new Font("Ubuntu", 1, 15));
        dLabel.setText("d:");

        dValue = new JTextField(6);
        dValue.setBackground(getBackground());
        dValue.setBorder(BorderFactory.createEmptyBorder());
        dValue.addKeyListener(new NavigableKeyActionListener());

        eLabel = new JLabel();
        eLabel.setFont(new Font("Ubuntu", 1, 15));
        eLabel.setText("e:");

        eValue = new JTextField(6);
        eValue.setBackground(getBackground());
        eValue.setBorder(BorderFactory.createEmptyBorder());
        eValue.addKeyListener(new NavigableKeyActionListener());
        
        GroupLayout progressPanelLayout = new GroupLayout(this);
        this.setLayout(progressPanelLayout);
        progressPanelLayout.setHorizontalGroup(
            progressPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(progressPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(progressPanelLayout.createParallelGroup(Alignment.LEADING)
                    .addGroup(progressPanelLayout.createSequentialGroup()
                        .addComponent(pLabel, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(ComponentPlacement.RELATED)
                        .addComponent(pValue, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE))
                    .addGroup(progressPanelLayout.createSequentialGroup()
                        .addComponent(qLabel)
                        .addGap(18, 18, 18)
                        .addComponent(qValue)))
                .addGap(71, 71, 71)
                .addGroup(progressPanelLayout.createParallelGroup(Alignment.LEADING, false)
                    .addComponent(phiLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(nLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(progressPanelLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(nValue)
                    .addComponent(phiValue))
                .addGap(130, 130, 130)
                .addGroup(progressPanelLayout.createParallelGroup(Alignment.LEADING)
                    .addGroup(progressPanelLayout.createSequentialGroup()
                        .addComponent(dLabel)
                        .addGap(18, 18, 18)
                        .addComponent(dValue))
                    .addGroup(progressPanelLayout.createSequentialGroup()
                        .addComponent(eLabel)
                        .addGap(18, 18, 18)
                        .addComponent(eValue)))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        progressPanelLayout.setVerticalGroup(
            progressPanelLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(progressPanelLayout.createSequentialGroup()
                .addGroup(progressPanelLayout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(pLabel)
                    .addComponent(pValue)
                    .addComponent(nLabel)
                    .addComponent(nValue)
                    .addComponent(dLabel)
                    .addComponent(dValue))
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addGroup(progressPanelLayout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(qLabel)
                    .addComponent(qValue)
                    .addComponent(phiLabel)
                    .addComponent(phiValue)
                    .addComponent(eLabel)
                    .addComponent(eValue))
                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
	}

	public String getPValue() {
		return pValue.getText();
	}

	public void setPValue(String pValue) {
		this.pValue.setText(pValue);
	}

	public String getQValue() {
		return qValue.getText();
	}

	public void setQValue(String qValue) {
		this.qValue.setText(qValue);
	}

	public String getNValue() {
		return nValue.getText();
	}

	public void setNValue(String nValue) {
		this.nValue.setText(nValue);
	}

	public String getPhiValue() {
		return phiValue.getText();
	}

	public void setPhiValue(String phiValue) {
		this.phiValue.setText(phiValue);
	}

	public String getDValue() {
		return dValue.getText();
	}

	public void setDValue(String dValue) {
		this.dValue.setText(dValue);
	}

	public String getEValue() {
		return eValue.getText();
	}

	public void setEValue(String eValue) {
		this.eValue.setText(eValue);
	}
}	

